package cate.common.table.position;


import cate.common.table.ERow;
import cate.common.table.XSSFRowWrap;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

import java.util.HashSet;
import java.util.Set;

@NoteClass("阵法配置")
public class PositionRow extends ERow {

    @NoteField("阵法ID")
    public int tid;

    @NoteField("名称")
    public String name;

    @NoteField("阵型")
    private String posStr;


    @Override
    public void parse(XSSFRowWrap xrw) {
        super.parse(xrw);
        this.id = xrw.getInteger("阵法ID",0);
        this.tid = xrw.getInteger("阵法ID",0);
        this.name = xrw.getString("名称");
        this.posStr = xrw.getString("阵型");

    }

    private Set<Byte> posSet = new HashSet<>();

    @Override
    public void decode() {
        if(StringUtils.isNotBlank(posStr)){
            for (String s : posStr.split("#")) {
                posSet.add(Byte.parseByte(s));
            }
        }
    }

    public boolean containPos(byte pos){
        return posSet.contains(pos);
    }
}
